#include <unistd.h>
#include <sys/types.h>

int main(int argc, char const *argv[])
{
        int fd[2];
        pipe(fd);
        pid_t pid = fork();
        if(pid == 0){
                //son
                close(fd[0]);
                write(fd[1], "hello", 5);
        }else if(pid > 0){
                //parent
                close(fd[1]);
                char buf[12] = {0};
                int len = read(fd[0], buf, sizeof(buf));
                if(len > 0){
                        write(STDOUT_FILENO, buf, len);
                }
        }
        return 0;
}
